package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.ShopUser;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QShopUser is a DSLite query type for ShopUser
 * @see ShopUser
 */
public class QShopUser extends QEntityBase<ShopUser> {

    public static final QShopUser $ = new QShopUser("SHOP_USER");

    public final StringColumn shopId = varchar("SHOP_ID", 22).field("shopId").notNull().build();

    public final StringColumn userId = varchar("USER_ID", 22).field("userId").notNull().build();

    public class Indexs {

        public final Index constraintIndex2a = index("CONSTRAINT_INDEX_2A").column(userId).build();

        public final Index constraintIndex2a7 = index("CONSTRAINT_INDEX_2A7").column(shopId).build();

        public final Index primaryKey2a = index("PRIMARY_KEY_2A").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint2a7 = foreignKey(userId, "AUTH_USER", "ID");

        public final ForeignKey constraint2a77 = foreignKey(shopId, "SHOP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QShopUser(String tableName) {
        super(ShopUser.class, tableName);
    }

    @Override
    public ShopUser newEntity() {
        return new ShopUser();
    }

    @Override
    public Object getFieldValue(ShopUser entity, String fieldName) {
        switch (fieldName) {
            case "shopId":
                return entity.getShopId();
            case "userId":
                return entity.getUserId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(ShopUser entity, String fieldName, Object value) {
        switch (fieldName) {
            case "shopId":
                entity.setShopId((java.lang.String) value);
                break;
            case "userId":
                entity.setUserId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

